perm filename TANGLX.DIF[WEB,ALS] blob
sn#621855 filedate 1981-11-03 generic text, type T, neo UTF8
1) TANGLE.WEB[WEB,DEK] and 2) TANGLX.WEB[WEB,ALS] 11-03-81 09:35 pages 1,1
**** File 1) TANGLE.WEB[WEB,DEK]/3P/1L
1) @* The \.{TANGLE} processor.
1) This program converts a \.{WEB} file to a \PASCAL\ file. It was written
**** File 2) TANGLX.WEB[WEB,ALS]/3P/1L
2) @* The TANGLE processor.
2) This program converts a \.{WEB} file to a \PASCAL\ file. It was written
***************
**** File 1) TANGLE.WEB[WEB,DEK]/4P/19L
1) begin write_ln(tty); print(#);
1) end
1) @ The following code re-opens the |input| file in a mode that (a)↔allows us
**** File 2) TANGLX.WEB[WEB,ALS]/4P/19L
2) begin write_ln(tty); print(#); end
2) @d ex_print_nl(#)==write_ln(tty); print(#)
2) @ The following code re-opens the |input| file in a mode that (a)↔allows us
***************
**** File 1) TANGLE.WEB[WEB,DEK]/4P/56L
1) begin print_nl('! Couldn''t open the pool file.'); quit;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/4P/56L
2) begin ex_print_nl('! Couldn''t open the pool file.'); quit;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/4P/86L
1) print_nl('! Input line too long'); error;
1) end
**** File 2) TANGLX.WEB[WEB,ALS]/4P/86L
2) ex_print_nl('! Input line too long'); error;
2) end
***************
**** File 1) TANGLE.WEB[WEB,DEK]/5P/32L
1) @d err_print(#)==begin print_nl(#); error;
1) end
1) @<Error handling...@>=
**** File 2) TANGLX.WEB[WEB,ALS]/5P/32L
2) @d err_print(#)==begin ex_print_nl(#); error; end
2) @d ex_err_print(#)==ex_print_nl(#); error
2) @<Error handling...@>=
***************
**** File 1) TANGLE.WEB[WEB,DEK]/5P/91L
1) @d confusion(#)==begin err_print('! This can''t happen (',#,')'); quit;
1) end
1) @ An overflow stop occurs if \.{TANGLE}'s tables aren't large enough.
1) @d overflow(#)==begin err_print('! Sorry, ',#,' capacity exceeded'); quit;
1) end
**** File 2) TANGLX.WEB[WEB,ALS]/5P/91L
2) @d confusion(#)==begin ex_err_print('! This can''t happen (',#,')'); quit;
2) end
2) @ An overflow stop occurs if \.{TANGLE}'s tables aren't large enough.
2) @d overflow(#)==begin ex_err_print('! Sorry, ',#,' capacity exceeded'); quit;
2) end
***************
**** File 1) TANGLE.WEB[WEB,DEK]/7P/146L
1) begin err_print('! This identifier has already appeared');
1) @<Remove $p$ from secondary hash table@>;
**** File 2) TANGLX.WEB[WEB,ALS]/7P/146L
2) begin ex_err_print('! This identifier has already appeared');
2) @<Remove $p$ from secondary hash table@>;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/7P/202L
1) print_nl('! Identifier conflict with ');
1) for k←byte_start[q] to byte_start[q+1]-1 do print(chr(byte_mem[k]));
**** File 2) TANGLX.WEB[WEB,ALS]/7P/202L
2) ex_print_nl('! Identifier conflict with ');
2) for k←byte_start[q] to byte_start[q+1]-1 do print(chr(byte_mem[k]));
***************
**** File 1) TANGLE.WEB[WEB,DEK]/8P/29L
1) begin err_print('! Incompatible module names'); p←0;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/8P/29L
2) begin ex_err_print('! Incompatible module names'); p←0;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/8P/41L
1) byte_ptr←byte_ptr+l; incr(name_ptr); byte_start[name_ptr]←byte_ptr;
1) @ @<Set $c$...@>=
1) begin k←byte_start[p]; c←equal; j←1;
1) while (k<byte_start[p+1]) ∧ (j≤l) ∧ (module[j]=byte_mem[k]) do
**** File 2) TANGLX.WEB[WEB,ALS]/8P/41L
2) byte_ptr←byte_ptr+l; incr(name_ptr); byte_start[name_ptr]←byte_ptr
2) @ @<Set $c$...@>=
2) k←byte_start[p]; c←equal; j←1;
2) while (k<byte_start[p+1]) ∧ (j≤l) ∧ (module[j]=byte_mem[k]) do
***************
**** File 1) TANGLE.WEB[WEB,DEK]/8P/53L
1) else c←greater;
1) end
1) @ The |prefix_lookup| procedure is supposed to find exactly one module
**** File 2) TANGLX.WEB[WEB,ALS]/8P/53L
2) else c←greater
2) @ The |prefix_lookup| procedure is supposed to find exactly one module
***************
**** File 1) TANGLE.WEB[WEB,DEK]/9P/47L
1) \yskip\hang |octal| denotes the |@@'| that precedes an octal constant.
1) \yskip\hang |param| denotes insertion of a parameter. This occurs only in
**** File 2) TANGLX.WEB[WEB,ALS]/9P/47L
2) \yskip\hang |octal| denotes the |@'| that precedes an octal constant.
2) \yskip\hang |param| denotes insertion of a parameter. This occurs only in
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/22L
1) yskip\noindent The current values of these four quantities are referred to
1) quite frequently, so they are stored in a separate place instead of in
**** File 2) TANGLX.WEB[WEB,ALS]/10P/22L
2) \yskip\noindent The current values of these four quantities are referred to
2) quite frequently, so they are stored in a separate place instead of in
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/72L
1) cur_byte←tok_start[cur_repl]; cur_end←tok_start[cur_repl+1];
1) @ When the replacement text for name $p$ is to be inserted into the output,
**** File 2) TANGLX.WEB[WEB,ALS]/10P/72L
2) cur_byte←tok_start[cur_repl]; cur_end←tok_start[cur_repl+1]
2) @ When the replacement text for name $p$ is to be inserted into the output,
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/146L
1) @<Expand module $a-@'24000$, |goto restart|@>
1) else begin cur_val←a-@'50000; a←module_number;
**** File 2) TANGLX.WEB[WEB,ALS]/10P/146L
2) @<Expand module |a-@'24000 , goto restart|@>
2) else begin cur_val←a-@'50000; a←module_number;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/159L
1) @<Expand module $a-...@>=
1) begin a←a-@'24000;
**** File 2) TANGLX.WEB[WEB,ALS]/10P/159L
2) @<Expand module ...@>=
2) begin a←a-@'24000;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/163L
1) begin print_nl('! Not present: <'); print_id(a); print('>'); error;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/10P/163L
2) begin ex_print_nl('! Not present: <'); print_id(a); print('>'); error;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/193L
1) begin print_nl('! No parameter given for '); print_id(a); error;
1) goto restart;
1) end;
1) @<Copy the parameter into |tok_mem|@>;
**** File 2) TANGLX.WEB[WEB,ALS]/10P/193L
2) begin ex_print_nl('! No parameter given for '); print_id(a); error;
2) goto restart;
2) end
2) @<Copy the parameter into |tok_mem|@>;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/10P/204L
1) text_link[text_ptr]←0; incr(text_ptr); tok_start[text_ptr]←tok_ptr;
1) @ The |pop_level| routine undoes the effect of parameter-pushing when
**** File 2) TANGLX.WEB[WEB,ALS]/10P/205L
2) text_link[text_ptr]←0; incr(text_ptr); tok_start[text_ptr]←tok_ptr
2) @ The |pop_level| routine undoes the effect of parameter-pushing when
**** File 1) TANGLE.WEB[WEB,DEK]/10P/231L
1) @d app_repl(#)==begin if tok_ptr=max_toks then overflow('token');
1) tok_mem[tok_ptr]←#; incr(tok_ptr); end
1) @<Copy the parameter...@>=
**** File 2) TANGLX.WEB[WEB,ALS]/10P/231L
2) Note: The |app_repl| macro is not enclosed with |begin| and |end|. Use with care.
2) @d app_repl(#)==if tok_ptr=max_toks then overflow('token');
2) tok_mem[tok_ptr]←#; incr(tok_ptr)
2) @<Copy the parameter...@>=
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/71L
1) sequence as we generate characters from `\.{(x-15+19-2)':
1) $$\vbox{\halign{#\hfil⊗\quad\hfil#\hfil⊗\quad\hfil#\hfil⊗\quad\hfil#\hfil⊗\quad
1) \hfil#\hfil\cr
1) |out_buf|⊗|out_state|⊗|out_sign|⊗|out_val|⊗|out_app|\cr
**** File 2) TANGLX.WEB[WEB,ALS]/11P/71L
2) sequence as we generate characters from `\.{(x-15+19-2)}':
2) $$\vbox{\halign{#\hfil⊗\quad\hfil#\hfil⊗\quad\hfil#\hfil⊗\quad
2) \hfil#\hfil⊗\quad\hfil#\hfil\cr
2) |out_buf|⊗|out_state|⊗|out_sign|⊗|out_val|⊗|out_app|\cr
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/113L
1) out_state←misc; out_ptr←0; break_ptr←0; out_buf[0]←0; line←1;
1) @ Here is a simple routine that is invoked when |out_ptr>line_length|
**** File 2) TANGLX.WEB[WEB,ALS]/11P/113L
2) out_state←misc; out_ptr←0; break_ptr←0; out_buf[0]←0; line←1
2) @ Here is a simple routine that is invoked when |out_ptr>line_length|
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/134L
1) begin err_print('! Long line must be truncated'); out_ptr←line_length;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/11P/134L
2) begin ex_err_print('! Long line must be truncated'); out_ptr←line_length;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/141L
1) break_ptr←out_ptr; flush_buffer;
1) @ Another simple and useful routine appends the decimal equivalent of
**** File 2) TANGLX.WEB[WEB,ALS]/11P/141L
2) break_ptr←out_ptr; flush_buffer
2) @ Another simple and useful routine appends the decimal equivalent of
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/149L
1) @p procedure app_val(v:integer); {puts $v$ into buffer, assumes $v≥0$}
**** File 2) TANGLX.WEB[WEB,ALS]/11P/148L
2) @d ex_app(#)==out_buf[out_ptr]←#; incr(out_ptr)
2) @p procedure app_val(v:integer); {puts $v$ into buffer, assumes $v≥0$}
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/154L
1) repeat incr(k); app(out_buf[k]+"0");
1) until k=out_buf_size; {then we append them, most significant first}
**** File 2) TANGLX.WEB[WEB,ALS]/11P/155L
2) repeat incr(k); ex_app(out_buf[k]+"0");
2) until k=out_buf_size; {then we append them, most significant first}
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/205L
1) sign: begin app(","-out_app); check_break; break_ptr←out_ptr;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/11P/206L
2) sign: begin ex_app(","-out_app); check_break; break_ptr←out_ptr;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/301L
1) begin break_ptr←out_ptr; app(" ");
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/11P/302L
2) begin break_ptr←out_ptr; ex_app(" ");
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/11P/305L
1) else begin app("("); app("-"); app_val(-v); app(")"); check_break;
1) out_state←misc;
**** File 2) TANGLX.WEB[WEB,ALS]/11P/306L
2) else begin ex_app("("); ex_app("-"); app_val(-v); ex_app(")"); check_break;
2) out_state←misc;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/12P/8L
1) else begin print_nl('Writing the output file...');
1) @<Initialize the output stacks@>;
**** File 2) TANGLX.WEB[WEB,ALS]/12P/8L
2) else begin ex_print_nl('Writing the output file...');
2) @<Initialize the output stacks@>;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/12P/13L
1) print_nl('Done.');
1) end
**** File 2) TANGLX.WEB[WEB,ALS]/12P/13L
2) ex_print_nl('Done.');
2) end
***************
**** File 1) TANGLE.WEB[WEB,DEK]/13P/33L
1) begin print_nl('! Couldn''t open the input file.'); quit;
1) end;
1) page←0; line←0; limit←0; loc←1; buffer[0]←" ";
1) input_has_ended←false;
1) @ The |get_line| procedure is called when |loc>limit|; it puts the next
**** File 2) TANGLX.WEB[WEB,ALS]/13P/33L
2) begin ex_print_nl('! Couldn''t open the input file.'); quit;
2) end;
2) page←0; line←0; limit←0; loc←1; buffer[0]←" ";
2) input_has_ended←false
2) @ The |get_line| procedure is called when |loc>limit|; it puts the next
***************
**** File 1) TANGLE.WEB[WEB,DEK]/13P/73L
1) until buffer[0]=form_feed
1) DROFNATS
**** File 2) TANGLX.WEB[WEB,ALS]/13P/73L
2) until buffer[0]=form_feed
2) DROFNATS
***************
**** File 1) TANGLE.WEB[WEB,DEK]/13P/151L
1) begin err_print('! Page ended in mid-comment');
1) loc←1; return;
**** File 2) TANGLX.WEB[WEB,ALS]/13P/151L
2) begin ex_err_print('! Page ended in mid-comment');
2) loc←1; return;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/13P/164L
1) else begin err_print('! Module ended in mid-comment');
1) decr(loc); return;
**** File 2) TANGLX.WEB[WEB,ALS]/13P/164L
2) else begin ex_err_print('! Module ended in mid-comment');
2) decr(loc); return;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/14P/81L
1) begin err_print('! String constant didn''t end'); d←"""";
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/14P/81L
2) begin ex_err_print('! String constant didn''t end'); d←"""";
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/14P/126L
1) begin err_print('! Page ended in module name');
1) loc←1; goto done;
**** File 2) TANGLX.WEB[WEB,ALS]/14P/126L
2) begin ex_err_print('! Page ended in module name');
2) loc←1; goto done;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/14P/139L
1) if (module[k]=" ")∧(k>0) then decr(k);
1) @ @<if end of name,...@>=
**** File 2) TANGLX.WEB[WEB,ALS]/14P/139L
2) if (module[k]=" ")∧(k>0) then decr(k)
2) @ @<if end of name,...@>=
***************
**** File 1) TANGLE.WEB[WEB,DEK]/14P/148L
1) begin err_print('! Module name didn''t end'); goto done;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/14P/148L
2) begin ex_err_print('! Module name didn''t end'); goto done;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/14P/155L
1) begin print_nl('! Module name too long: ');
1) for j←1 to 25 do print(chr(module[j]));
**** File 2) TANGLX.WEB[WEB,ALS]/14P/155L
2) begin ex_print_nl('! Module name too long: ');
2) for j←1 to 25 do print(chr(module[j]));
***************
**** File 1) TANGLE.WEB[WEB,DEK]/15P/36L
1) begin err_print('! Value too big: ',accumulator:0); accumulator←0;
1) end;
**** File 2) TANGLX.WEB[WEB,ALS]/15P/36L
2) begin ex_err_print('! Value too big: ',accumulator:0); accumulator←0;
2) end;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/15P/66L
1) end;
1) done:
1) @ @<Signal error, flush rest...@>=
1) begin err_print('! Improper numeric definition will be flushed');
1) repeat next_control←skip_ahead
**** File 2) TANGLX.WEB[WEB,ALS]/15P/66L
2) end
2) done:
2) @ @<Signal error, flush rest...@>=
2) begin ex_err_print('! Improper numeric definition will be flushed');
2) repeat next_control←skip_ahead
***************
**** File 1) TANGLE.WEB[WEB,DEK]/15P/83L
1) until (next_control>"9")∨(next_control<"0");
1) @ @<Set |val| to value of octal...@>=
**** File 2) TANGLX.WEB[WEB,ALS]/15P/83L
2) until (next_control>"9")∨(next_control<"0")
2) @ @<Set |val| to value of octal...@>=
***************
**** File 1) TANGLE.WEB[WEB,DEK]/15P/88L
1) until (next_control>"7")∨(next_control<"0");
1) @* Scanning a macro definition.
**** File 2) TANGLX.WEB[WEB,ALS]/15P/88L
2) until (next_control>"7")∨(next_control<"0")
2) @* Scanning a macro definition.
***************
**** File 1) TANGLE.WEB[WEB,DEK]/16P/56L
1) begin err_print('! Missing ',bal:0,' )');
1) while bal>0 do
**** File 2) TANGLX.WEB[WEB,ALS]/16P/56L
2) begin ex_err_print('! Missing ',bal:0,' )');
2) while bal>0 do
***************
**** File 1) TANGLE.WEB[WEB,DEK]/16P/71L
1) else begin err_print('! @@',chr(buffer[loc-1]),
1) ' is ignored in PASCAL text'); goto continue;
**** File 2) TANGLX.WEB[WEB,ALS]/16P/71L
2) else begin ex_err_print('! @@',chr(buffer[loc-1]),
2) ' is ignored in PASCAL text'); goto continue;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/16P/83L
1) begin err_print('! String didn''t end');
1) buffer[loc]←"'"; buffer[loc+1]←0;
**** File 2) TANGLX.WEB[WEB,ALS]/16P/83L
2) begin ex_err_print('! String didn''t end');
2) buffer[loc]←"'"; buffer[loc+1]←0;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/32L
1) begin err_print('! Definition flushed, must start with ',
1) 'identifier of length > 1'); goto continue;
**** File 2) TANGLX.WEB[WEB,ALS]/17P/32L
2) begin ex_err_print('! Definition flushed, must start with ',
2) 'identifier of length > 1'); goto continue;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/44L
1) err_print('! Definition flushed since it starts badly');
1) end;
1) done:
**** File 2) TANGLX.WEB[WEB,ALS]/17P/44L
2) ex_err_print('! Definition flushed since it starts badly');
2) end
2) done:
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/56L
1) begin err_print('! Use == for macros');
1) next_control←equivalence_sign;
**** File 2) TANGLX.WEB[WEB,ALS]/17P/56L
2) begin ex_err_print('! Use == for macros');
2) next_control←equivalence_sign;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/64L
1) end;
1) @ @<Scan the \PASCAL...@>=
**** File 2) TANGLX.WEB[WEB,ALS]/17P/64L
2) end
2) @ @<Scan the \PASCAL...@>=
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/82L
1) begin err_print('! PASCAL text flushed, = sign is missing');
1) repeat next_control←skip_ahead;
**** File 2) TANGLX.WEB[WEB,ALS]/17P/82L
2) begin ex_err_print('! PASCAL text flushed, = sign is missing');
2) repeat next_control←skip_ahead;
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/86L
1) end;
1) @ @<Insert the module number...@>=
1) store_two_bytes(@'150000+module_count); {|@'150000=@'320*@'400|}
1) @ @<Update the data...@>=
**** File 2) TANGLX.WEB[WEB,ALS]/17P/86L
2) end
2) @ @<Insert the module number...@>=
2) store_two_bytes(@'150000+module_count) {|@'150000=@'320*@'400|}
2) @ @<Update the data...@>=
***************
**** File 1) TANGLE.WEB[WEB,DEK]/17P/100L
1) text_link[cur_repl_text]←module_flag; {mark this replacement text as a nonmacro}
1) @* Debugging.
**** File 2) TANGLX.WEB[WEB,ALS]/17P/100L
2) text_link[cur_repl_text]←module_flag {mark this replacement text as a nonmacro}
2) @* Debugging.
***************
**** File 1) TANGLE.WEB[WEB,DEK]/19P/27L
1) phase_one←false;
1) @ @<Print statistics about memory usage@>=
1) print_nl('Memory usage statistics:');
1) print_nl(name_ptr:0, ' names, ', text_ptr:0, ' replacement texts;');
1) print_nl(byte_ptr:0, ' bytes, ', max_tok_ptr:0, ' tokens.');
**** File 2) TANGLX.WEB[WEB,ALS]/19P/27L
2) phase_one←false
2) @ @<Print statistics about memory usage@>=
2) ex_print_nl('Memory usage statistics:');
2) ex_print_nl(name_ptr:0, ' names, ', text_ptr:0, ' replacement texts;');
2) ex_print_nl(byte_ptr:0, ' bytes, ', max_tok_ptr:0, ' tokens.')
2) @* Index.
2) If you have read and understood the code for Phase III in \.{WEAVE}, you
2) know what is in this index and how it got here. All modules in which an
2) identifier is used are listed with that identifier, except that reserved
2) words are indexed only when they appear in format definitions, and the
2) appearances of identifiers in module names are not indexed. Underlined
2) entries correspond to where the identifier was declared.
***************